package cn.edu.zjicm.wordsnet_d.synchronize;

import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import android.content.Context;

public class ServerInterface {

	// 通知UI刷新的handler和msg常量
	public static final int MSG_START = 0; 					// 开始
	public static final int MSG_SUCCESS = 1; 				// 成功
	public static final int MSG_BAD_NETWORK = 2; 			// 网络链接错误
	public static final int MSG_REGISTERED = 3; 			// 已被注册
	public static final int MSG_NOT_REGISTERED = 4; 		// 未注册
	public static final int MSG_INCORRECT_PASSWORD = 5; 	// 密码和用户名不匹配
	public static final int MSG_WEB_SITE_ACCESS_FAILURE = 6;// 无法访问web site
	public static final int MSG_WEB_SITE_ERROR = 10;		// 服务器错误
	public static final int MSG_UNSUCCESS = 7; 				// 失败
	public static final int MSG_WRONG_PASSWORD = 8; 		// 修改密码时提交的原密码错误
	public static final int MSG_WRONG_PHOTO = 9; 			// 修改密码时提交的原密码错误
	
	public static final String MSG_BAD_NETWORK_STRING 				= "请确认网络是否连接";
	public static final String MSG_WEB_SITE_ACCESS_FAILURE_STRING 	= "服务器太忙，请稍后再试";	//无法访问网站，请确认网络是否连接

//	public static final String IP = "http://112.124.114.203"; 	//测试服务器
	public static final String IP = "http://114.215.182.172"; 	//线上发布服务器
//	public static final String IP = "http://192.168.0.115";   //聪哥测试  
	
	public static final String PORT = ":8080";
//	public static final String INNER_REGISTER_URL = 	IP + PORT + "/youqu/registerInner.htm";
	public static final String REGISTER_URL = 			IP + PORT + "/youqu/register.htm";
//	public static final String INNER_LOGIN_URL = 		IP + PORT + "/youqu/loginInner.htm";
	public static final String LOGIN_URL = 				IP + PORT + "/youqu/login.htm";
	public static final String LOGIN_Weixin_URL = 		IP + PORT + "/youqu/loginByWeChatInner.htm";	//微信登录
	public static final String INNER_SYNC_URL = 		IP + PORT + "/youqu/syncInner.htm";	
	public static final String MODIFY_PASSWORD_URL = 	IP + PORT + "/youqu/changePwd.htm";
	public static final String INNER_CHANGE_NICKNAME = 	IP + PORT + "/youqu/saveNickNameInner.htm";
	public static final String INNER_PUNCH_TODAY = 		IP + PORT + "/youqu/punchInInner.htm";			//打卡
	public static final String INNER_PUNCH_YESTERDAY =  IP + PORT + "/youqu/punchInInnerYesterDay.htm";		//获取系统真实日期
	public static final String INNER_GET_PUNCH = 		IP + PORT + "/youqu/getPunchInInner.htm";		//获取打卡数据
	public static final String GET_REAL_DATE = 		    IP + PORT + "/youqu/getCurrentDate.htm";		//获取系统真实日期
	public static final String UPLOAD = 				IP + PORT + "/youqu/upload.htm";				//上传头像
	public static final String HEAD_URL = 				"http://youqu-dev.oss-cn-hangzhou.aliyuncs.com/";	//下载头像地址
	public static final String SET_SCHOOL_ID =			IP + PORT + "/youqu/setSchoolID.htm";			//设置学校
	public static final String SET_EXP =				IP + PORT + "/youqu/setExp.htm";				//设置经验值
	public static final String GET_EXP =				IP + PORT + "/youqu/getExp.htm";				//获取经验值
	public static final String FEED_BACK_INNER = 		IP + PORT + "/youqu/feedbackInner.htm";			//意见反馈，暂未使用
	
	public static final String SEND_FORGET_MAIL = 		IP + PORT + "/youqu/sendForgetMailInner.htm";
	public static final String VALIDATE_CODE = 			IP + PORT + "/youqu/validateCodeInner.htm";
//	public static final String CHANGE_PWD_INNER = 		IP + PORT + "/youqu/changePwdWithCodeInner.htm";
	public static final String CHANGE_PWD = 			IP + PORT + "/youqu/changePwdWithCode.htm";
	
	public static final String GET_PUNCH_BOARD = 		IP + PORT + "/youqu/getUserPunchinBoardBySchool.htm";	//打卡榜
	public static final String GET_EXP_BOARD = 			IP + PORT + "/youqu/getUserExpBoardBySchool.htm";		//单词学校榜
	public static final String GET_SCHOOL_BOARD = 		IP + PORT + "/youqu/getSchoolBoard.htm";				//学校榜
	
	public static final String GET_SCHOOL1 = 			IP + PORT + "/youqu/getUniversityByProvince.htm";		//大学
	public static final String GET_SCHOOL2 = 			IP + PORT + "/youqu/getHighSchoolByRegion.htm";			//高中
	public static final String GET_SCHOOL3 = 			IP + PORT + "/youqu/getCollegeSchoolByRegion.htm";		//中专技校
	public static final String GET_SCHOOL4 = 			IP + PORT + "/youqu/getMiddleSchoolByRegion.htm";		//初中
	
	public static final String SYNC_URL = 				IP + PORT + "/youqu/sync.htm";					//暂未使用
	public static final String INNER_CHECK_NICKNAME = 	IP + PORT + "/youqu/checkNickNameInner.htm";	//暂未使用
	
	public static final String GET_COMMODITY_LIST	=	IP + PORT + "/youqu/getCommodityList.htm";		//获取商品信息
	public static final String GET_USER_WEALTH		=	IP + PORT + "/youqu/getUserWealth.htm";			//获取用户财富值
	public static final String GET_USER_BOUGHT		=	IP + PORT + "/youqu/getUserBought.htm";			//获取已购买商品信息
	public static final String BUY_WITH_ZMD			=	IP + PORT + "/youqu/buyWithZmd.htm";			//购买商品
	public static final String CREATE_ALIPAY_ORDER	=	IP + PORT + "/youqu/createAlipayOrder.htm";		//购买商品
	
	Context context;

	protected ServerInterface(Context context) {
		this.context = context;
	}
	
	public static void setClientTimeout(DefaultHttpClient client) {
		HttpParams params = client.getParams(); 					// 计算网络超时用.
		HttpConnectionParams.setConnectionTimeout(params, 15000); 	// 原为30000，连接时间
		HttpConnectionParams.setSoTimeout(params, 60000); 			// 原为60000，返回数据时间socket time
		
		//这是临时测试，发布按照上面的代码
//		HttpConnectionParams.setConnectionTimeout(params, 30000); 	// 原为30000，连接时间
//		HttpConnectionParams.setSoTimeout(params, 60000*3); 			// 原为60000，返回数据时间socket time
	}

}
